'use strict'
const fs = require('fs');

class template {

    constructor() {
        this.param = '/'
    }
    //创建资源
    async get(c) {
        var url = c.param.starPath;
        var openid = c.box.user.openid;
        try {
            var r1 = await c.service.psql.query(`select user_id from users where openid = '${openid}'`);
            var user_id = r1.rows[0].user_id;
            var r2 = await c.service.psql.query(`select sticker_id from user_${user_id}_pay_sti`);

            let r3 =await c.service.psql.query( `select * from sticker`);
            if(r3.rowCount==0){
                return c.send('no data');
            }
            c.send({
                user_own:r2.rows,
                sticker:r3.rows
            });
            return
        }
        catch (err) {
            console.log(err);
            c.status(500).send('error');
        }
    }

}


module.exports = template
